export default {
  inserted: function(el) {
    let isScrolling = false;
    let scrollInterval;

    function startScroll() {
      if (!isScrolling) {
        isScrolling = true;
        scrollInterval = setInterval(function() {
          el.scrollLeft += 1;
        }, 10);
      }
    }

    function stopScroll() {
      if (isScrolling) {
        isScrolling = false;
        clearInterval(scrollInterval);
      }
    }

    el.addEventListener('mouseenter', startScroll);
    el.addEventListener('mouseleave', stopScroll);
  }
}
